package main

import (
	"fmt"
	"os"
	"io/ioutil"
	"bufio"
)

func main()  {
	
	content,err := ioutil.ReadFile("d:\\golang_workstation\\write.txt")
	if err != nil {
		fmt.Println("打开文件出错，错误：",err)
		return
	}

	file,err2 := os.OpenFile("d:\\golang_workstation\\test.txt",
	os.O_WRONLY | os.O_CREATE,0777)
	
	if err2 != nil {
		fmt.Println("打开目标文件出错，错误：",err)
		return
	}

	defer file.Close()

	writer := bufio.NewWriter(file)
	writer.WriteString(string(content))
	writer.Flush()

}
